package Ioperations;

import book.Bookshelf;

import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28318
 * Date: 2025-10-28
 * Time: 17:32
 */
public class FindIoperation implements Ioperations{
    @Override
    public void work(Bookshelf book) {
        System.out.println("***>查找图书...<***");
        Scanner inPut = new Scanner(System.in);
        System.out.println("请输入您要查找的书名:");
        String name = inPut.nextLine();
        int address = -1;
        for (int i = 0; i < book.getBookUsed(); i++) {
            if(book.bookshelf[i].getName().equals(name)){
                address = i;
                System.out.println("您要找图书信息如下:");
                System.out.println(book.bookshelf[address]);
                break;
            }
        }
        if (address == -1){
            System.out.println("未找到您要查找的图书...");
        }
    }
}
